<?php echo $documentForm['document_iden']?>
<?php echo $documentForm['_csrf_token']?>
<?php echo $invoiceForm['invoice_iden']?>
<?php echo $invoiceForm['customer_iden']?>
<?php echo $invoiceForm['_csrf_token']?>
<div class="infobox1">
              <table>
                <tr>
                  <th class="field"><?php echo $documentForm['owner_iden']->renderLabel()?></th>
                  <td class="field">
                    <?php echo $documentForm['owner_iden']->renderError()?>
                    <?php echo $documentForm['owner_iden']?>
                  </td>
                </tr>
                <tr>
                  <th class="field"><?php echo $documentForm['counter_code']->renderLabel()?></th>
                  <td class="field">
                    <?php echo $documentForm['counter_code']->renderError()?>
                    <?php echo $documentForm['counter_code']?>
                  </td>
                </tr>
                <tr>
                  <th class="field"><?php echo $invoiceForm['invoice_name']->renderLabel()?></th>
                  <td class="field">
                    <?php echo $invoiceForm['invoice_name']->renderError()?>
                    <?php echo $invoiceForm['invoice_name']?>
                  </td>
                </tr>
                <tr>
                  <th class="field"><?php echo $invoiceForm['invoice_type']->renderLabel()?></th>
                  <td class="field">
                    <?php echo $invoiceForm['invoice_type']->renderError()?>
                    <?php echo $invoiceForm['invoice_type']?>
                    <?php echo $invoiceForm['invoice_id']->renderError()?>
                    <?php echo $invoiceForm['invoice_id']?>
                  </td>
                </tr>
                <tr>
                  <th class="field"><?php echo $documentForm['document_date']->renderLabel()?></th>
                  <td class="field">
                    <?php echo $documentForm['document_date']->renderError()?>
                    <?php echo $documentForm['document_date']?>
                  </td>
                </tr>
                <tr>
                  <th class="field"><?php echo $invoiceForm['vat_excempt_type']->renderLabel()?></th>
                  <td class="field">
                    <?php echo $invoiceForm['vat_excempt_type']->renderError()?>
                    <?php echo $invoiceForm['vat_excempt_type']?>
                  </td>
                </tr>
                <tr>
                  <th class="field"><?php echo $invoiceForm['delivery_date']->renderLabel()?></th>
                  <td class="field">
                    <?php echo $invoiceForm['delivery_date']->renderError()?>
                    <?php echo $invoiceForm['delivery_date']?>
                  </td>
                </tr>
                <tr>
                  <th class="field"><?php echo $invoiceForm['delivery_mode']->renderLabel()?></th>
                  <td class="field">
                    <?php echo $invoiceForm['delivery_mode']->renderError()?>
                    <?php echo $invoiceForm['delivery_mode']?>
                  </td>
                </tr>
                <tr>
                  <th class="field"><?php echo $invoiceForm['delivery_details']->renderLabel()?></th>
                  <td class="field">
                    <?php echo $invoiceForm['delivery_details']->renderError()?>
                    <?php echo $invoiceForm['delivery_details']?>
                  </td>
                </tr>
                <tr>
                  <th class="field"><?php echo $invoiceForm['terms_name']->renderLabel()?></th>
                  <td class="field">
                    <?php echo $invoiceForm['terms_name']->renderError()?>
                    <?php echo $invoiceForm['terms_name']?>
                  </td>
                </tr>
                <tr>
                  <th class="field"><?php echo $invoiceForm['days_due']->renderLabel()?></th>
                  <td class="field">
                    <?php echo $invoiceForm['days_due']->renderError()?>
                    <?php echo $invoiceForm['days_due']?>
                  </td>
                </tr>
                <tr>
                  <th class="field"><?php echo $invoiceForm['remarks']->renderLabel()?></th>
                  <td class="field">
                    <?php echo $invoiceForm['remarks']->renderError()?>
                    <?php echo $invoiceForm['remarks']?>
                  </td>
                </tr>
              </table>
            </div>
<script language="javascript">
  $(document).ready(function(){
    $('#invoice_invoice_id').blur(function(){
      $.getJSON(
        'invoice/checkId',
        {
          "invoice_iden":$('#invoice_invoice_iden').val(),
          "invoice_type":$('#invoice_invoice_type').val(),
          "invoice_id":$('#invoice_invoice_id').val(),
        },
        function(data){
          if(data.count > 0){
            invoice_id = $('#invoice_invoice_type').val()+'-'+$('#invoice_invoice_id').val();
            alert(invoice_id+' already exists.');
          }
        }
      );
    });
  });
</script>